home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Science
/
RLaB
/
examples
/
primes.r
< prev
next >
Wrap
Text File
|
1994-04-25
|
340b
|
23 lines
//
// An example that finds all primes less than limit
//
primes = function (limit) {
local(prime, cnt, i, j, k);
i = 1; j = 0; cnt = 0;
for(k in 2:limit)
{
j = 2;
while(mod(k,j) != 0) {
j++;
}
if(j == k) { // Found prime
cnt++;
prime[1;i] = k;
i++;
}
}
return prime;
}